#include "scenepause.h"

ScenePause::ScenePause(SceneTypes type)
{
	this->type = type;
}

void ScenePause::init(State& state, Graphics& graphics)
{
	/* init default view */
	auto& something = register_drawable(
		graphics.load_png_to_texture("res/img/1607284670491.png")
	);
	something.render_data.dst.move(state.window_w / 4, 0);
	something.render_data.dst.scale(state.window_w / 2, state.window_h);
	something.register_sprite(Sprite(something.render_data.texture));

	bool* exit_scene = &state.exit_scene;
	auto& something_else = register_button(
		graphics.load_png_to_texture("res/img/play.png"),
		[exit_scene](){ *exit_scene = true; }
	);
	something_else.render_data.dst.move(state.window_w * 0.75, state.window_h / 2);
	something_else.render_data.dst.scale(state.window_w / 5, state.window_h / 2);
	something_else.register_sprite(Sprite(something_else.render_data.texture));
}

void ScenePause::cleanup()
{
	Scene::cleanup();
}

void ScenePause::update(State& state, bool pressed_keys[])
{
	if (pressed_keys[Input::KEY_ESCAPE]) {
		pressed_keys[Input::KEY_ESCAPE] ^= 1;
		state.last_scene = true;
	}
}

void ScenePause::render(SDL_Renderer *renderer)
{
	ui_layer.render(renderer);
}